<template>
	<div>
		<el-form ref="queryForm" :inline="true">
			<el-form-item label="班级：" style="width: 300px;">
				<el-select placeholder="班级" v-model="classeNum">
					<el-option v-for="item in classeEnum" :key="item.id" :value="item.id" :label="item.qtype">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="submitForm">查询</el-button>
				<el-button type="danger" @click="paperGenerator">组卷</el-button>
			</el-form-item>
			</el-form>
		<el-table v-loading="loading" :data="tableData" border fit highlight-current-row >
		  
		  <el-table-column prop="paperName" label="试卷名称" align="center"/>
		  <el-table-column prop="class" label="班级" width="100px" align="center"/>
		  <el-table-column prop="learningStage" label="学习阶段" width="100px" align="center"/>
		  <el-table-column label="状态" width="100px" align="center">
			  <template slot-scope="{row}">
				  <el-switch @change="publish(row.id)" active-value="1" inactive-value="0" v-model="row.status"></el-switch>
			  </template>
		  </el-table-column>
		  <el-table-column prop="dateTime" label="考试开始时间" align="center">
		  </el-table-column>
		  <el-table-column label="操作" align="center">
		    <template slot-scope="{row}">
			  <el-button size="mini"  @click="editPaper(row)">编辑</el-button>
		      <el-button size="mini"  type="danger" @click="deletePaper(row)" class="link-left">删除</el-button>
		    </template>
		  </el-table-column>
		</el-table>
	</div>

</template>

<script>
	export default{
		data(){
			return{
				classeNum:'',
				classeEnum:[
					{
						id:'1',
						qtype:'java35'
					},
					{
						id:'2',
						qtype:'java36'
					}
				],
				loading:false,
				tableData:[
					{
						id:'1',
						paperName:'第一次考试',
						class:'java35',
						learningStage:'java新技术',
						dateTime:'2019-08-29 11:00:00',
						status:0
					},
				],
				
			}
		},
		created() {
			
		},
		methods:{
			publish(row){
				let flag=-1;
				for (let item in this.$data.tableData) {
					flag++;
					if(item.id==row.id){
						break;
					}
				}
				if(row.status==1){
					this.$data.tableData[flag].status=0;
				}
				
				if(row.status==0)
				{
					this.$data.tableData[flag].status=1;
				}
			},
			editPaper(row){
				this.$router.push({path:'/paper/list/edit',query:{id:row.id}})
			},
			deletePaper(row){
				let flag=-1;
				for (let item in this.$data.tableData) {
					flag++;
					if(item.id==row.id){
						break;
					}
				}
				this.$data.tableData.splice(flag,1);
			},
			paperGenerator(){
				this.$router.push({path:'/paper/list/edit'})
			},
			submitForm(){}
			
		}
	}
</script>

<style>
</style>
